home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / xgui / sources / ui_mainP.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-25  |  52.0 KB  |  1,798 lines

  1. /*****************************************************************************
  2.   FILE           : ui_mainP.c
  3.   SHORTNAME      : mainP.c
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        :
  7.   PURPOSE        : contains callback routines of the gui window 
  8.   NOTES          :
  9.  
  10.   AUTHOR         : Tilman Sommer
  11.   DATE           : 1.4.1990
  12.  
  13.   CHANGED BY     : Michael Vogt, Guenter Mamier
  14.   IDENTIFICATION : @(#)ui_mainP.c    1.19 3/2/94
  15.   SCCS VERSION   : 1.19 
  16.   LAST CHANGE    : 3/2/94  
  17.  
  18.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  19.              
  20. ******************************************************************************/
  21.  
  22.  
  23. #include <ctype.h>           
  24. #include <stdio.h>            /* For the Syntax message */
  25. #include <stdlib.h>
  26. #include <malloc.h>
  27. #include <sys/types.h>
  28. #include <sys/stat.h>
  29.  
  30. #include "ui.h"
  31.  
  32. #include <X11/Shell.h>
  33.  
  34. #include <X11/cursorfont.h>
  35. #include <X11/Xaw/MenuButton.h>
  36. #include <X11/Xaw/Text.h>
  37. #include <X11/Xaw/TextSrc.h>
  38. #include <X11/Xaw/Form.h>
  39. #include <X11/Xaw/Box.h>
  40. #include <X11/Xaw/Cardinals.h>
  41. #include <X11/Xaw/Command.h>
  42. #include <X11/Xaw/Dialog.h>
  43. #include <X11/Xaw/List.h>
  44. #include <X11/Xaw/AsciiText.h>
  45.  
  46. #include "kr_ui.h"
  47.  
  48. #include "ui_info.h"
  49. #include "ui_setup.h"
  50. #include "ui_layer.h"
  51. #include "ui_layerP.h"
  52. #include "ui_file.h"
  53. #include "ui_fileP.h"
  54. #include "ui_netGraph.h"
  55. #include "ui_netUpdate.h"
  56. #include "ui_event.h"
  57. #include "ui_key.h"
  58. #include "ui_confirmer.h"
  59. #include "ui_xWidgets.h"
  60. #include "ui_lists.h"
  61. #include "ui_display.h"
  62. #include "ui_remote.h"
  63. #include "ui_remoteP.h"
  64. #include "ui_edit.h"
  65. #include "ui_xGraphic.h"
  66. #include "ui_textP.h"
  67. #include "ui_funcdispl.h"
  68. #include "ui_action.h"
  69. #include "ui_result.h"
  70. #include "ui_main.h"
  71. #include "ui_print.h"
  72. #include "ui_color.h"
  73.  
  74.  
  75. #include "ui_mainP.ph"
  76.  
  77.  
  78. /*****************************************************************************
  79.   FUNCTION : ui_createGC
  80.  
  81.   PURPOSE  : create the GC and load the graphic font
  82.   RETURNS  : void
  83.   NOTES    : window is any existing window of a widget on the screen used by
  84.              xgui. 
  85.   UPDATE   : 20.9.1990
  86. ******************************************************************************/
  87.  
  88. void ui_xCreateGC (Window window)
  89.  
  90. {
  91.     int i, count;
  92.     char buf[255];
  93.     char **fontList;
  94.  
  95.     if (hasCmdlineFont) {
  96.         ui_fontStruct = XLoadQueryFont(ui_display, ui_fontName);
  97.         if (ui_fontStruct == 0) {
  98.              ui_tw_errorMessage("Can't find display font specified in command line");
  99.              exit(1);
  100.     }else{
  101.             fontList = XListFonts(ui_display, ui_fontName, 1, &count);
  102.             if (count != 0) { 
  103.                 sprintf (buf, "Font %s loaded\n", *fontList);
  104.                 ui_tw_printMessage(buf);
  105.             }
  106.             XFreeFontNames(fontList);
  107.         }
  108.     } else {
  109.         for (i=0; i<noOfFontNames; i++) {
  110.             ui_fontStruct = XLoadQueryFont(ui_display, ui_fontNames[i]);
  111.             if (ui_fontStruct != 0) {
  112.                fontList = XListFonts(ui_display, ui_fontNames[i], 1, &count);
  113.                if (count != 0) { 
  114.                    sprintf (buf, "Font %s loaded\n", *fontList);
  115.                    ui_tw_printMessage(buf);
  116.            }
  117.                XFreeFontNames(fontList);
  118.                break;
  119.         }
  120.         }
  121.         if (ui_fontStruct == 0) {
  122.             ui_tw_errorMessage("Can't find ISO 8859 Font");
  123.             exit(1);
  124.         }
  125.     }
  126.  
  127.     ui_gcValues.line_width = 0;
  128.     ui_gcValues.line_style = LineSolid;
  129.     /* Set (or get) the next two attributes, because ui_drawUnit() 
  130.        in the file ui_netGraphics.c need this information */
  131.     ui_gc = 
  132.     XCreateGC(ui_display, window, GCLineWidth | GCLineStyle, 
  133.           &ui_gcValues);
  134.     XSetFunction(ui_display,ui_gc, GXcopy);
  135.     XSetFont(ui_display, ui_gc, ui_fontStruct->fid);
  136. }
  137.  
  138.  
  139. /*****************************************************************************
  140.   FUNCTION : ui_printMessage
  141.  
  142.   PURPOSE  : display a message in the manager panel 
  143.   RETURNS  : void
  144.   NOTES    :
  145.  
  146.   UPDATE   : 1.2.1990
  147. ******************************************************************************/
  148.  
  149. void ui_printMessage (char *msgString)
  150.  
  151. {
  152.     ui_xSetLabel(ui_message, msgString);
  153.     XFlush(ui_display);
  154. }
  155.  
  156.  
  157. /*****************************************************************************
  158.   FUNCTION : ui_displayDone
  159.  
  160.   PURPOSE  : close a xgui display
  161.   RETURNS  : void
  162.   NOTES    :
  163.  
  164.   UPDATE   : 1.2.1990
  165. ******************************************************************************/
  166.  
  167. void ui_displayDone (Widget widget, struct Ui_DisplayType *displayPtr, 
  168.      caddr_t call_data)
  169.  
  170. {
  171.     XtDestroyWidget(XtParent(displayPtr->frameWidget));
  172.     displayPtr->frameWidget = NULL;
  173.     displayPtr->widget      = NULL;
  174.     displayPtr->drawable    = 0;
  175.     ui_displ_freeItem(displayPtr);
  176. }
  177.  
  178.  
  179. /*****************************************************************************
  180.   FUNCTION : ui_helpDone
  181.  
  182.   PURPOSE  : close a xgui help window
  183.   RETURNS  : void
  184.   NOTES    :
  185.  
  186.   UPDATE   : 1.2.1990
  187. ******************************************************************************/
  188.  
  189. /*ARGSUSED*/
  190. static void ui_helpDone (Widget widget, struct HelpType *helpPtr, caddr_t call_data)
  191.  
  192. {
  193.     struct HelpType *listPtr;
  194.  
  195.     if (ui_help_listPtr == helpPtr) {
  196.     ui_help_listPtr     = helpPtr->nextPtr;
  197.     helpPtr->nextPtr    = ui_help_freeListPtr;
  198.     ui_help_freeListPtr = helpPtr;
  199.     XtDestroyWidget(helpPtr->shellWidget);
  200.     } else {
  201.     listPtr = ui_help_listPtr;
  202.     while (listPtr->nextPtr != NULL AND listPtr->nextPtr != helpPtr) 
  203.         listPtr = listPtr->nextPtr;
  204.     
  205.     if (listPtr->nextPtr == helpPtr) {
  206.         listPtr->nextPtr    = helpPtr->nextPtr;
  207.         helpPtr->nextPtr    = ui_help_freeListPtr;
  208.         ui_help_freeListPtr = helpPtr;
  209.         XtDestroyWidget(helpPtr->shellWidget);
  210.     }
  211.     }
  212. }
  213.  
  214.  
  215. /*****************************************************************************
  216.   FUNCTION : ui_listPopupDone
  217.  
  218.   PURPOSE  : close a list panel
  219.   RETURNS  : void
  220.   NOTES    :
  221.  
  222.   UPDATE   : 1.2.1990
  223. ******************************************************************************/
  224.  
  225. static void ui_listPopupDone (Widget widget, 
  226.     struct SimpleListType *listDescriptorPtr, caddr_t call_data)
  227.  
  228. {
  229.     int i;
  230.  
  231.     XtDestroyWidget(ui_popList);
  232.     ui_pop_exit = TRUE; /* signal to leave temporary event loop */
  233.     XFlush(ui_display);
  234.  
  235.     /* keep the allocated space of the array, but free all the space
  236.        of valid strings */
  237.     for (i = 1; i<= listDescriptorPtr->noOfItems; i++) 
  238.     free((listDescriptorPtr->listPtr)[i-1]);
  239.     listDescriptorPtr->noOfItems = 0;
  240. }
  241.  
  242.  
  243. /*****************************************************************************
  244.   FUNCTION : ui_editPopupDone
  245.  
  246.   PURPOSE  : close a edit panel
  247.   RETURNS  : void
  248.   NOTES    :
  249.  
  250.   UPDATE   : 1.2.1990
  251. ******************************************************************************/
  252.  
  253. static void ui_editPopupDone (Widget widget, 
  254.     struct SimpleListType *listDescriptorPtr, caddr_t call_data)
  255.  
  256. {
  257.     int i;
  258.  
  259.     XtDestroyWidget(ui_popEdit);
  260.  
  261.     /* keep the allocated space of the array, but free all the space
  262.        of valid strings */
  263.     for (i = 1; i<= listDescriptorPtr->noOfItems; i++) 
  264.     free((listDescriptorPtr->listPtr)[i-1]);
  265.     listDescriptorPtr->noOfItems = 0;
  266. }
  267.  
  268.  
  269. /*****************************************************************************
  270.   FUNCTION : ui_popupDone
  271.  
  272.   PURPOSE  : close other panels and windows
  273.   RETURNS  : void
  274.   NOTES    :
  275.  
  276.   UPDATE   : 1.2.1990
  277. ******************************************************************************/
  278.  
  279. /*ARGSUSED*/
  280. void ui_popupDone (Widget widget, int client_data, caddr_t call_data)
  281.  
  282. {
  283.     char buf[80];
  284.     int  gridSize;
  285.  
  286.     switch (client_data) {
  287.       case UI_POPUP_DUMMY:
  288.     XtDestroyWidget(ui_popDummy);
  289.     break;
  290.       case UI_POPUP_SETUP: 
  291.     ui_setupIsCreated = FALSE;
  292.     gridSize  = 
  293.         ui_xIntFromAsciiWidget(ui_set_gridWidthWidget);
  294.     if (gridSize >= 1) 
  295.         ui_set_displayPtr->gridSize = gridSize;
  296.     ui_set_displayPtr->origin.x  = 
  297.         ui_xIntFromAsciiWidget(ui_set_originXWidget);
  298.     ui_set_displayPtr->origin.y  = 
  299.         ui_xIntFromAsciiWidget(ui_set_originYWidget);
  300.     ui_set_displayPtr->subNetNo  = 
  301.         ui_xIntFromAsciiWidget(ui_set_subnetWidget);
  302.     sprintf(buf,"snns-display %d - subnet: %d",
  303.         ui_set_displayPtr->displayNo, 
  304.         ui_set_displayPtr->subNetNo);
  305.     ui_actualZvalue  =  ui_xIntFromAsciiWidget(ui_set_zWidget);
  306.     XStoreName(ui_display, 
  307.            XtWindow(XtParent(ui_set_displayPtr->frameWidget)), 
  308.            buf);
  309.     ui_net_completeRefresh(ui_set_displayPtr, UI_LOCAL);
  310.     XtDestroyWidget(ui_popSetup);
  311.     break;
  312.       case UI_POPUP_FILE:   
  313.     ui_fileIsCreated = FALSE;
  314.         ui_filePannelPoppedUp = FALSE;
  315.     XtDestroyWidget(ui_popFile);
  316.     break;
  317.       case UI_POPUP_LAYER:
  318.     ui_layer_setLayerNames();
  319.     XtDestroyWidget(ui_popLayer);
  320.     ui_pop_exit = TRUE; /* signal to leave temporary loop */
  321.     XFlush(ui_display);
  322.     break;
  323.       case UI_POPUP_REMOTE:
  324.     ui_remoteIsCreated = FALSE;
  325.     XtDestroyWidget(ui_popRemote);
  326.     break;
  327.       case UI_POPUP_WEIGHTS_DONE:
  328.     XtDestroyWidget(ui_popInit);
  329.     ui_pop_exit = TRUE; /* signal to leave temporary loop */
  330.     break;
  331.       case UI_POPUP_WEIGHTS_CANCEL:
  332.     XtDestroyWidget(ui_popWeights);
  333.     ui_pop_exit = TRUE; /* signal to leave temporary loop */
  334.     XFlush(ui_display);
  335.         break;
  336.       case UI_POPUP_RESULT:
  337.         XtDestroyWidget(ui_popResult);
  338.         ui_ResultIsCreated = FALSE;
  339.      break;
  340.       case UI_POPUP_SUBPATTERN:
  341.     if(NO_OF_PATTERN_SETS != 0)ui_rem_getSubPatPanel();
  342.     XtDestroyWidget(ui_popPattern);
  343.     SubPatPanel = 0;
  344.     break;
  345.     }
  346.     ui_printMessage("");
  347. }
  348.  
  349.  
  350. /*****************************************************************************
  351.   FUNCTION : ui_rem_initNet
  352.  
  353.   PURPOSE  : 
  354.   RETURNS  : void
  355.   NOTES    :
  356.  
  357.   UPDATE   : 18.3.1991
  358. ******************************************************************************/
  359.  
  360. void ui_rem_initNet (Widget button, int randomType, caddr_t call_data)
  361.  
  362. {
  363.     Widget      doneButton, form, label, title, sbutton;
  364.     Arg        args[5];
  365.     Position    x, y;
  366.     Dimension    width, height;
  367.     Cardinal    n;
  368.     XEvent      event;
  369.     char        buf[120];
  370.     int         i;
  371.  
  372.     /* Upper left corner will be in the center of the calling button */
  373.  
  374.     ui_xGetDimensions(button, &width, &height);
  375.     XtTranslateCoords(button, (Position) (width / 2), 
  376.               (Position) (height / 2),
  377.               &x, &y);
  378.     
  379.     n = 0;
  380.     XtSetArg(args[n], XtNx, x);    n++;
  381.     XtSetArg(args[n], XtNy, y);    n++;
  382.     
  383.     /* Now create Popup */
  384.     
  385.     ui_popInit = 
  386.     XtCreatePopupShell("initialize net", transientShellWidgetClass, ui_toplevel,
  387.                args, n);
  388.     
  389.     form = 
  390.     XtCreateManagedWidget("form", formWidgetClass, ui_popInit, 
  391.                   NULL, ZERO);
  392.  
  393.     title =
  394.     ui_xCreateLabelItem("Initialize net", form, 14*8, NULL, NULL);
  395.  
  396.     sprintf(buf,"using: %s", krui_getInitialisationFunc()); 
  397.     title =
  398.     ui_xCreateLabelItem("title", form, 10*8, NULL, title);
  399.     ui_xSetResize(title, TRUE);
  400.     ui_xSetLabel(title, buf);
  401.  
  402.     label =
  403.     ui_xCreateLabelItem("parameters:", form, 11*8, NULL, title);
  404.     
  405.     for (i=0; i< UI_NO_INIT_PARAMS; i++) {
  406.     sprintf(buf,"%9.3f", ui_initParameters[i]);
  407.     ui_initParameterWidgets[i] =
  408.         ui_xCreateDialogItem("param", form, buf, 9*8, 
  409.                  (i==0 OR i==3) ? label : 
  410.                  ui_initParameterWidgets[i-1], 
  411.                  i<3 ? title : ui_initParameterWidgets[0]);
  412.     }
  413.  
  414.     doneButton = 
  415.     ui_xCreateButtonItem("done", form, NULL, ui_initParameterWidgets[0]);
  416.     XtAddCallback(doneButton, XtNcallback, (XtCallbackProc) ui_popupDone, (caddr_t) UI_POPUP_WEIGHTS_DONE);
  417.     /*!*/  /* constant name is meaningless ! */
  418.  
  419.     sbutton = 
  420.     ui_xCreateButtonItem("init", form, doneButton, ui_initParameterWidgets[0]);
  421.     XtAddCallback(sbutton, XtNcallback, (XtCallbackProc) ui_rem_doInitialization, NULL);
  422.     
  423.     ui_checkWindowPosition(ui_popInit);
  424.     XtPopup(ui_popInit, XtGrabExclusive);
  425.     ui_xDontResizeWidget(ui_popInit); 
  426.  
  427.     ui_pop_exit = FALSE;
  428.     while (NOT ui_pop_exit) { /* exit after pressing the DONE button */
  429.     XtAppNextEvent(ui_appContext, &event);
  430.     (void) XtDispatchEvent(&event);
  431.     }
  432. }
  433.  
  434.  
  435. /*****************************************************************************
  436.   FUNCTION : ui_popupWeights
  437.  
  438.   PURPOSE  : popup of random/jog weights
  439.   RETURNS  : void
  440.   NOTES    :
  441.  
  442.   UPDATE   : 27.5.1990
  443. ******************************************************************************/
  444.  
  445. void ui_popupWeights (Widget button, int randomType, caddr_t call_data)
  446.  
  447. {
  448.     Widget      doneButton, form, label, title, sbutton;
  449.     Arg        args[5];
  450.     Position    x, y;
  451.     Dimension    width, height;
  452.     Cardinal    n;
  453.     XEvent      event;
  454.  
  455.     /* Upper left corner will be in the center of the calling button */
  456.  
  457.     ui_xGetDimensions(button, &width, &height);
  458.     XtTranslateCoords(button, (Position) (width / 2), 
  459.               (Position) (height / 2),
  460.               &x, &y);
  461.     
  462.     n = 0;
  463.     XtSetArg(args[n], XtNx, x);    n++;
  464.     XtSetArg(args[n], XtNy, y);    n++;
  465.     
  466.     /* Now create Popup */
  467.     
  468.     ui_popWeights = 
  469.     XtCreatePopupShell("jog weights", transientShellWidgetClass, ui_toplevel,
  470.                args, n);
  471.     
  472.     form = 
  473.     XtCreateManagedWidget("form", formWidgetClass, ui_popWeights, 
  474.                   NULL, ZERO);
  475.  
  476.     title =
  477.     ui_xCreateLabelItem("set link weights:", form, 20*8, NULL, NULL);
  478.     ui_xSetResize(title, TRUE);
  479.  
  480.     label =
  481.     ui_xCreateLabelItem("low  limit:", form, 11*8, NULL, title);
  482.  
  483.     ui_lowLimitWidget =
  484.     ui_xCreateDialogItem("lowLimit", form, "-0.001", 9*8, label, title);
  485.  
  486.     label =
  487.     ui_xCreateLabelItem("high limit:", form, 11*8, NULL, ui_lowLimitWidget);
  488.  
  489.     ui_highLimitWidget =
  490.     ui_xCreateDialogItem("highLimit", form, "0.001", 9*8, label, ui_lowLimitWidget);
  491.  
  492.     doneButton = 
  493.     ui_xCreateButtonItem("done", form, NULL, ui_highLimitWidget);
  494.     XtAddCallback(doneButton, XtNcallback, (XtCallbackProc) ui_popupDone, (caddr_t) UI_POPUP_WEIGHTS_CANCEL);
  495.  
  496.     sbutton = 
  497.     ui_xCreateButtonItem("set", form, doneButton, ui_highLimitWidget);
  498.     XtAddCallback(sbutton, XtNcallback, (XtCallbackProc) ui_rem_setRandomWeights, (caddr_t) randomType);
  499.     
  500.     ui_checkWindowPosition(ui_popWeights);
  501.     XtPopup(ui_popWeights, XtGrabExclusive);
  502.     ui_xDontResizeWidget(ui_popWeights); 
  503.  
  504.     ui_pop_exit = FALSE;
  505.     while (NOT ui_pop_exit) { /* exit after pressing the DONE button */
  506.     XtAppNextEvent(ui_appContext, &event);
  507.     (void) XtDispatchEvent(&event);
  508.     }
  509. }
  510.  
  511.  
  512. /*****************************************************************************
  513.   FUNCTION : ui_editPopup
  514.  
  515.   PURPOSE  : edit popup of f-types
  516.   RETURNS  : void
  517.   NOTES    :
  518.  
  519.   UPDATE   : 27.8.1990
  520. ******************************************************************************/
  521.  
  522. void ui_editPopup (Widget w, struct SimpleListType *listDescriptorPtr, 
  523.     caddr_t call_data)
  524.  
  525. {
  526.     Widget      doneButton, abutton, form, actLabel, label, button;
  527.     Arg        args[10];
  528.     Position    x, y;
  529.     Dimension    width, height;
  530.     Cardinal    n;
  531.  
  532.     /* Upper left corner will be in the center of the calling button */
  533.  
  534.     n = 0;
  535.     XtSetArg(args[0], XtNwidth, &width); n++;
  536.     XtSetArg(args[1], XtNheight, &height); n++;
  537.     XtGetValues(listDescriptorPtr->widgetPtr, args, n);
  538.     XtTranslateCoords(listDescriptorPtr->widgetPtr,
  539.               (Position) (width / 2), (Position) (height / 2),
  540.               &x, &y);
  541.  
  542.     n = 0;
  543.     XtSetArg(args[n], XtNx, x);    n++;
  544.     XtSetArg(args[n], XtNy, y);    n++;
  545.  
  546.     /* Now create Popup */
  547.  
  548.     ui_popEdit = 
  549.     XtCreatePopupShell("edit f-types", transientShellWidgetClass, ui_toplevel,
  550.                args, n);
  551.  
  552.     form = 
  553.     XtCreateManagedWidget("form", formWidgetClass, ui_popEdit, 
  554.                   NULL, ZERO);
  555.  
  556.     
  557.     label = 
  558.     ui_xCreateLabelItem("msg", form, 14*8, NULL, NULL);
  559.     ui_xSetLabel(label, "Edit f-type");
  560.     ui_xSetResize(label, TRUE);
  561.  
  562.     ui_edit_ftypeNameWidget = 
  563.     ui_xCreateDialogItem("name", form, "", 25*8, label, NULL);
  564.  
  565.     button =
  566.     ui_xCreateButtonItem("select", form, NULL, label);
  567.     XtAddCallback(button, XtNcallback, (XtCallbackProc) ui_edit_selectFunction, 
  568.           (caddr_t) UI_EDIT_ACT_FUNC);
  569.  
  570.     actLabel = 
  571.     ui_xCreateLabelItem("actFunc", form, 11*8, button, label);
  572.     ui_xSetLabel(actLabel, "act. func.:");
  573.  
  574.     ui_edit_actFuncNameWidget = 
  575.     ui_xCreateLabelItem("actFuncName", form, 25*8, actLabel, label);
  576.     ui_xSetResize(ui_edit_actFuncNameWidget, TRUE);
  577.     ui_xSetLabel(ui_edit_actFuncNameWidget,"");
  578.     
  579.     button =
  580.     ui_xCreateButtonItem("select", form, NULL, actLabel);
  581.     XtAddCallback(button, XtNcallback, (XtCallbackProc) ui_edit_selectFunction, 
  582.           (caddr_t) UI_EDIT_OUT_FUNC);
  583.  
  584.     label = 
  585.     ui_xCreateLabelItem("outFunc", form, 11*8, button, actLabel);
  586.     ui_xSetLabel(label, "out. func.:");
  587.  
  588.     ui_edit_outFuncNameWidget = 
  589.     ui_xCreateLabelItem("outFuncName", form, 25*8, label, actLabel);
  590.     ui_xSetResize(label, TRUE);
  591.     ui_xSetLabel(ui_edit_outFuncNameWidget,"");
  592.  
  593. /*    button =
  594.     ui_xCreateMenuButtonItem("icon", form, NULL, label);
  595.     label =
  596.     ui_xCreateLabelItem("box", form, 11*8, button, label);
  597. */
  598.     abutton =
  599.     ui_xCreateButtonItem("add", form, NULL, label);
  600.     XtAddCallback(abutton, XtNcallback, (XtCallbackProc) ui_edit_ftypeAddSite, 
  601.           (caddr_t) listDescriptorPtr);
  602.  
  603.     button =
  604.     ui_xCreateButtonItem("delete", form, abutton, label);
  605.     XtAddCallback(button, XtNcallback, (XtCallbackProc) ui_edit_ftypeDeleteSite, 
  606.           (struct SimpleListType *) listDescriptorPtr);
  607.     
  608.     n = 0; 
  609.     XtSetArg(args[n], XtNfromHoriz, button ); n++;
  610.     XtSetArg(args[n], XtNfromVert , label   ); n++;
  611.     XtSetArg(args[n], XtNleft  , XtChainLeft); n++;
  612.     XtSetArg(args[n], XtNright , XtChainLeft); n++;
  613.     XtSetArg(args[n], XtNtop   , XtChainTop ); n++;
  614.     XtSetArg(args[n], XtNbottom, XtChainTop ); n++;
  615.  
  616.     listDescriptorPtr->listWidget =
  617.     XtCreateManagedWidget("list", listWidgetClass, form, args, n);
  618.     ui_list_buildList(listDescriptorPtr);
  619.     ui_xSetResize(listDescriptorPtr->listWidget, TRUE);
  620.    /* XtAddCallback(listDescriptorPtr->listWidget, XtNcallback, 
  621.           ui_edit_listSetSite, UI_EDIT_FTYPE);
  622.           */
  623.    
  624.     doneButton = 
  625.     ui_xCreateButtonItem("done", form, NULL, 
  626.                  listDescriptorPtr->listWidget);
  627.     XtAddCallback(doneButton, XtNcallback, (XtCallbackProc) ui_editPopupDone, 
  628.           (struct SimpleListType *) listDescriptorPtr);
  629.  
  630.     button =
  631.     ui_xCreateButtonItem("choose", form, doneButton, 
  632.                  listDescriptorPtr->listWidget);
  633.     XtAddCallback(button, XtNcallback, (XtCallbackProc) ui_edit_chooseFType, 
  634.           (struct SimpleListType *) listDescriptorPtr);
  635.  
  636.     button =
  637.     ui_xCreateButtonItem("set", form, button, 
  638.                  listDescriptorPtr->listWidget);
  639.     XtAddCallback(button, XtNcallback, (XtCallbackProc) ui_edit_setFType, 
  640.           (struct SimpleListType *) listDescriptorPtr);
  641.  
  642.     button =
  643.     ui_xCreateButtonItem("new", form, button, 
  644.                  listDescriptorPtr->listWidget);
  645.     XtAddCallback(button, XtNcallback, (XtCallbackProc) ui_edit_newFType, 
  646.           (struct SimpleListType *) listDescriptorPtr);
  647.  
  648.     button =
  649.     ui_xCreateButtonItem("delete", form, button, 
  650.                  listDescriptorPtr->listWidget);
  651.     XtAddCallback(button, XtNcallback, (XtCallbackProc) ui_edit_deleteFType, 
  652.           (struct SimpleListType *) listDescriptorPtr);
  653.  
  654.  
  655.     ui_edit_displayFirstFType(listDescriptorPtr);
  656.  
  657.     XawFormDoLayout(form, True);
  658.     ui_checkWindowPosition(ui_popEdit);
  659.     XtPopup(ui_popEdit, XtGrabExclusive);
  660.     ui_xDontResizeWidget(ui_popEdit); 
  661. }
  662.  
  663.  
  664. /*****************************************************************************
  665.   FUNCTION : ui_editSitePopup
  666.  
  667.   PURPOSE  : edit popup (sites)
  668.   RETURNS  : void
  669.   NOTES    :
  670.  
  671.   UPDATE   : 27.9.1990
  672. ******************************************************************************/
  673.  
  674. void ui_editSitePopup (Widget w, struct SimpleListType *listDescriptorPtr, 
  675.     caddr_t call_data)
  676.  
  677. {
  678.     Widget      doneButton, form, actLabel, label, button, sbutton;
  679.     Arg        args[10];
  680.     Position    x, y;
  681.     Dimension    width, height;
  682.     Cardinal    n;
  683.     char        *name, *func;
  684.  
  685.     /* Upper left corner will be in the center of the calling button */
  686.  
  687.     n = 0;
  688.     XtSetArg(args[0], XtNwidth, &width); n++;
  689.     XtSetArg(args[1], XtNheight, &height); n++;
  690.     XtGetValues(listDescriptorPtr->widgetPtr, args, n);
  691.     XtTranslateCoords(listDescriptorPtr->widgetPtr,
  692.               (Position) (width / 2), (Position) (height / 2),
  693.               &x, &y);
  694.  
  695.     n = 0;
  696.     XtSetArg(args[n], XtNx, x);    n++;
  697.     XtSetArg(args[n], XtNy, y);    n++;
  698.  
  699.     /* Now create Popup */
  700.  
  701.     ui_popEdit = 
  702.     XtCreatePopupShell("edit sites", transientShellWidgetClass, ui_toplevel,
  703.                args, n);
  704.  
  705.     form = 
  706.     XtCreateManagedWidget("form", formWidgetClass, ui_popEdit, 
  707.                   NULL, ZERO);
  708.  
  709.     
  710.     label = 
  711.     ui_xCreateLabelItem("msg", form, 14*8, NULL, NULL);
  712.     ui_xSetResize(label, TRUE);
  713.     ui_xSetLabel (label, "Edit site");
  714.  
  715.     ui_edit_siteNameWidget = 
  716.     ui_xCreateDialogItem("name", form, "", 25*8, label, NULL);
  717.  
  718.     button =
  719.     ui_xCreateButtonItem("select", form, NULL, label);
  720.     XtAddCallback(button, XtNcallback, (XtCallbackProc) ui_edit_selectFunction, (caddr_t) UI_EDIT_SITE_FUNC);
  721.        
  722.     actLabel = 
  723.     ui_xCreateLabelItem("SiteFunc", form, 11*8, button, label);
  724.     ui_xSetLabel(actLabel, "site func.:");
  725.  
  726.     ui_edit_siteFuncNameWidget = 
  727.     ui_xCreateLabelItem("name", form, 25*8, actLabel, label);
  728.     ui_xSetResize(ui_edit_siteFuncNameWidget, TRUE);
  729.  
  730.     doneButton = 
  731.     ui_xCreateButtonItem("done", form, NULL, button);
  732.     XtAddCallback(doneButton, XtNcallback, (XtCallbackProc) ui_editPopupDone, 
  733.           (struct SimpleListType *) listDescriptorPtr);
  734.  
  735.     sbutton =
  736.     ui_xCreateButtonItem("set", form, doneButton, button);
  737.     XtAddCallback(sbutton, XtNcallback, (XtCallbackProc) ui_edit_setSite, 
  738.           (struct SimpleListType *) listDescriptorPtr);
  739.  
  740.     n = 0; 
  741.     XtSetArg(args[n], XtNfromHoriz, NULL); n++;
  742.     XtSetArg(args[n], XtNfromVert , sbutton);  n++;
  743.     XtSetArg(args[n], XtNleft  , XtChainLeft); n++;
  744.     XtSetArg(args[n], XtNright , XtChainLeft); n++;
  745.     XtSetArg(args[n], XtNtop   , XtChainTop); n++;
  746.     XtSetArg(args[n], XtNbottom, XtChainTop); n++;
  747.  
  748.     listDescriptorPtr->listWidget =
  749.     XtCreateManagedWidget("list", listWidgetClass, form, args, n);
  750.     ui_list_buildList(listDescriptorPtr);
  751.     XtAddCallback(listDescriptorPtr->listWidget, XtNcallback, 
  752.           (XtCallbackProc) ui_edit_listSetSite, (caddr_t) UI_EDIT_SITE);
  753.     ui_xSetResize(listDescriptorPtr->listWidget, TRUE);
  754.     
  755.     if (krui_getFirstSiteTableEntry(&name, &func)) 
  756.     XawListHighlight(listDescriptorPtr->listWidget, 1);
  757.     /* name is NULL, if there is no first site ! */
  758.     ui_edit_setCurrentSite(name);
  759.  
  760.     button =
  761.     ui_xCreateButtonItem("new", form, listDescriptorPtr->listWidget, sbutton);
  762.     XtAddCallback(button, XtNcallback, (XtCallbackProc) ui_edit_newSite, 
  763.           (struct SimpleListType *) listDescriptorPtr);
  764.  
  765.     button =
  766.     ui_xCreateButtonItem("delete", form, button, sbutton);
  767.     XtAddCallback(button, XtNcallback, (XtCallbackProc) ui_edit_deleteSite, 
  768.           (struct SimpleListType *) listDescriptorPtr);
  769.     
  770.     if (krui_getFirstSiteTableEntry(&name, &func)) {
  771.     sprintf(ui_edit_siteName,"%s",name);
  772.     sprintf(ui_edit_siteFuncName,"%s",func);
  773.     ui_xSetLabel(ui_edit_siteFuncNameWidget, ui_edit_siteFuncName);
  774.     ui_xSetString(ui_edit_siteNameWidget, ui_edit_siteName);
  775.     }
  776.  
  777.     ui_checkWindowPosition(ui_popEdit);
  778.     XtPopup(ui_popEdit, XtGrabExclusive);
  779.     ui_xDontResizeWidget(ui_popEdit); 
  780. }
  781.  
  782.  
  783. /*****************************************************************************
  784.   FUNCTION : ui_listPopup
  785.  
  786.   PURPOSE  : popup a list panel
  787.   RETURNS  : void
  788.   NOTES    :
  789.  
  790.   UPDATE   : 27.8.1990
  791. ******************************************************************************/
  792.  
  793. void ui_listPopup (struct SimpleListType *listDescriptorPtr, Position x, 
  794.     Position y)
  795.  
  796. {
  797.     Widget      doneButton, form, label;
  798.     char        buf[80], title[80];
  799.     Arg        args[6];
  800.     Cardinal    n;
  801.     XEvent      event;
  802.  
  803.     /* Upper left corner will be in the center of the calling button */
  804.  
  805.     n = 0;
  806.     XtSetArg(args[n], XtNx, x);    n++;
  807.     XtSetArg(args[n], XtNy, y);    n++;
  808.  
  809.     /* Now create Popup */
  810.  
  811.     sprintf (title, listDescriptorPtr->msg);
  812.     title[0] = tolower(title[0]);  
  813.     ui_popList = 
  814.     XtCreatePopupShell(title, transientShellWidgetClass, ui_toplevel,
  815.                            args, n);
  816.  
  817.     form = 
  818.     XtCreateManagedWidget("form", formWidgetClass, ui_popList, 
  819.                   NULL, ZERO);
  820.  
  821.     label = 
  822.     ui_xCreateLabelItem("msg", form, 80*8, NULL, NULL);
  823.     ui_xSetResize(label, TRUE);
  824.     ui_xSetLabel(label, listDescriptorPtr->msg);
  825.  
  826.     if ((listDescriptorPtr->unitPtr != NULL) AND 
  827.     (listDescriptorPtr->unitPtr->no != ZERO)) {
  828.     label = 
  829.         ui_xCreateLabelItem("msg", form, 80*8, NULL, label);
  830.     ui_xSetResize(label, TRUE);
  831.     sprintf(buf,"unit #%d - %s", 
  832.         listDescriptorPtr->unitPtr->no, 
  833.         listDescriptorPtr->unitPtr->name);
  834.     ui_xSetLabel(label, buf);
  835.     }
  836.  
  837.     n = 0; 
  838.     XtSetArg(args[n], XtNfromHoriz, NULL); n++;
  839.     XtSetArg(args[n], XtNfromVert , label);  n++;
  840.     XtSetArg(args[n], XtNleft  , XtChainLeft); n++;
  841.     XtSetArg(args[n], XtNright , XtChainLeft); n++;
  842.     XtSetArg(args[n], XtNtop   , XtChainTop); n++;
  843.     XtSetArg(args[n], XtNbottom, XtChainTop); n++;
  844.  
  845.     listDescriptorPtr->listWidget =
  846.     XtCreateManagedWidget("list", listWidgetClass, form, args, n);
  847.     ui_list_buildList(listDescriptorPtr);
  848.     XtAddCallback(listDescriptorPtr->listWidget, XtNcallback, 
  849.           (XtCallbackProc) ui_list_setUnitValue, 
  850.           (struct SimpleListType  *) listDescriptorPtr);
  851.     ui_list_returnIndex = XAW_LIST_NONE;
  852.  
  853. /* NEW for Unitfunction Display */
  854.  
  855.     if ((listDescriptorPtr->unitPtr != NULL) AND 
  856.     (listDescriptorPtr->unitPtr->no != ZERO)) {
  857.       if( listDescriptorPtr->unitPtr->no == ui_sourceUnit.no){
  858.         if(listDescriptorPtr->listType == UI_LIST_ACT_FUNC){
  859.       XtAddCallback(listDescriptorPtr->listWidget, XtNcallback, 
  860.                 (XtCallbackProc) ui_drawFunction,"Source Act");
  861.         }else if(listDescriptorPtr->listType == UI_LIST_OUT_FUNC){
  862.       XtAddCallback(listDescriptorPtr->listWidget, XtNcallback, 
  863.                 (XtCallbackProc) ui_drawFunction,"Source Out");
  864.         }
  865.       }else {
  866.         if(listDescriptorPtr->listType == UI_LIST_ACT_FUNC){
  867.       XtAddCallback(listDescriptorPtr->listWidget, XtNcallback, 
  868.                 (XtCallbackProc) ui_drawFunction,"Target Act");
  869.         }else if(listDescriptorPtr->listType == UI_LIST_OUT_FUNC){
  870.       XtAddCallback(listDescriptorPtr->listWidget, XtNcallback, 
  871.                 (XtCallbackProc) ui_drawFunction,"Target Out");
  872.         }
  873.       }
  874.     }
  875.  
  876. /*end New */
  877.  
  878.     doneButton = 
  879.     ui_xCreateButtonItem("done", form, NULL, listDescriptorPtr->listWidget);
  880.     XtAddCallback(doneButton, XtNcallback, (XtCallbackProc) ui_listPopupDone, 
  881.           (struct SimpleListType  *) listDescriptorPtr);
  882.  
  883.     ui_checkWindowPosition(ui_popList);
  884.     XtPopup(ui_popList, XtGrabExclusive);
  885.     ui_xDontResizeWidget(ui_popList); 
  886.  
  887.     ui_pop_exit = FALSE;
  888.     while (NOT ui_pop_exit) { /* exit after pressing the DONE button */
  889.     XtAppNextEvent(ui_appContext, &event);
  890.     (void) XtDispatchEvent(&event);
  891.     }
  892. }
  893.  
  894.  
  895. /*****************************************************************************
  896.   FUNCTION : ui_popupSetup
  897.  
  898.   PURPOSE  : popup a setup panel
  899.   RETURNS  : void
  900.   NOTES    :
  901.  
  902.   UPDATE   : 27.5.1990
  903. ******************************************************************************/
  904.  
  905. static void ui_popupSetup (Widget button, struct Ui_DisplayType *displayPtr, 
  906.     caddr_t call_data)
  907.  
  908. {
  909.     Widget      doneButton;
  910.     Arg        args[5];
  911.     Position    x, y;
  912.     Dimension    width, height;
  913.     Cardinal    n;
  914.  
  915.     /* Upper left corner will be in the center of the calling button */
  916.  
  917.     if (NOT ui_setupIsCreated) {
  918.  
  919.     n = 0;
  920.     XtSetArg(args[0], XtNwidth, &width); n++;
  921.     XtSetArg(args[1], XtNheight, &height); n++;
  922.     XtGetValues(button, args, n);
  923.     XtTranslateCoords(button, (Position) (width / 2), 
  924.               (Position) (height / 2),
  925.               &x, &y);
  926.  
  927.     n = 0;
  928.     XtSetArg(args[n], XtNx, x);    n++;
  929.     XtSetArg(args[n], XtNy, y);    n++;
  930.  
  931.     /* Now create Popup */
  932.  
  933.     ui_popSetup = 
  934.         XtCreatePopupShell("setup", transientShellWidgetClass, 
  935.                    ui_toplevel, args, n);
  936.  
  937.     ui_setupBox = 
  938.         XtCreateManagedWidget("form", formWidgetClass, ui_popSetup, 
  939.                   NULL, ZERO);
  940.  
  941.     ui_xCreateSetupPanel(ui_setupBox, displayPtr);
  942.  
  943.     doneButton = 
  944.         ui_xCreateButtonItem("done", ui_setupBox, NULL, ui_setupPanel);
  945.     XtAddCallback(doneButton, XtNcallback, (XtCallbackProc) ui_popupDone, 
  946.         (caddr_t) UI_POPUP_SETUP);
  947.  
  948.     ui_setupSliderMessage = 
  949.         ui_xCreateLabelItem("", ui_setupBox, 30*8, 
  950.                 doneButton, ui_setupPanel);
  951.     ui_checkWindowPosition(ui_popSetup);
  952.     XtPopup(ui_popSetup, XtGrabExclusive);
  953.         ui_xDontResizeWidget(ui_popSetup); 
  954.     }
  955. }
  956.  
  957.  
  958. /*****************************************************************************
  959.   FUNCTION : ui_displayFilePanel
  960.  
  961.   PURPOSE  : popup the file panel
  962.   RETURNS  : void
  963.   NOTES    :
  964.  
  965.   UPDATE   : 22.5.1990
  966. ******************************************************************************/
  967.  
  968. void ui_displayFilePanel (Widget w, Widget button, caddr_t call_data)
  969.  
  970. {
  971.     Widget      doneButton;
  972.     Arg        args[5];
  973.     Position    x, y;
  974.     Dimension    width, height;
  975.     Cardinal    n;
  976.  
  977.     if (ui_filePannelPoppedUp)
  978.         return;
  979.     ui_filePannelPoppedUp = TRUE;
  980.  
  981.     /* Upper left corner will be in the center of the calling button */
  982.  
  983.     n = 0;
  984.     XtSetArg(args[0], XtNwidth, &width); n++;
  985.     XtSetArg(args[1], XtNheight, &height); n++;
  986.     XtGetValues(button, args, n);
  987.  
  988.     XtTranslateCoords(button, (Position) 0, (Position) (height),
  989.               &x, &y);
  990.  
  991.     n = 0;
  992.     XtSetArg(args[n], XtNx, x);    n++;
  993.     XtSetArg(args[n], XtNy, y);    n++;
  994.  
  995.     /* Now create Popup */
  996.  
  997.     ui_popFile = 
  998.     XtCreatePopupShell("file browser", transientShellWidgetClass, button,
  999.                args, n);
  1000.  
  1001.     ui_fileBox = 
  1002.     XtCreateManagedWidget("box", boxWidgetClass, ui_popFile, NULL, ZERO);
  1003.  
  1004.     ui_xCreateFilePanel(ui_fileBox);
  1005.  
  1006.     doneButton = 
  1007.     ui_xCreateButtonItem("done", ui_fileBox, NULL, ui_filePanel);
  1008.     XtAddCallback(doneButton, XtNcallback, (XtCallbackProc) ui_popupDone, (caddr_t) UI_POPUP_FILE);
  1009.     ui_fileIsCreated = TRUE;
  1010.     ui_checkWindowPosition(ui_popFile);
  1011.     XtPopup(ui_popFile, XtGrabNone);
  1012. }
  1013.  
  1014.  
  1015. /*****************************************************************************
  1016.   FUNCTION : ui_displayLayerPanel
  1017.  
  1018.   PURPOSE  : popup the layer panel
  1019.   RETURNS  : void
  1020.   NOTES    :
  1021.  
  1022.   UPDATE   : 22.5.1990
  1023. ******************************************************************************/
  1024.  
  1025. void ui_displayLayerPanel (Position x, Position y)
  1026.  
  1027. {
  1028.     Widget      doneButton, layerBox;
  1029.     Arg        args[5];
  1030.     Cardinal    n;
  1031.     XEvent      event;
  1032.  
  1033.     /* Upper left corner will be in the center of the calling button */
  1034.  
  1035.     n = 0;
  1036.     XtSetArg(args[n], XtNx, x);    n++;
  1037.     XtSetArg(args[n], XtNy, y);    n++;
  1038.     ui_popLayer = 
  1039.     XtCreatePopupShell("layers", transientShellWidgetClass, ui_toplevel,
  1040.                args, n);
  1041.  
  1042.     layerBox = 
  1043.     XtCreateManagedWidget("box", boxWidgetClass, ui_popLayer, NULL, ZERO);
  1044.  
  1045.     ui_xCreateLayerPanel(layerBox);
  1046.  
  1047.     doneButton = 
  1048.     ui_xCreateButtonItem("done", layerBox, NULL, NULL);
  1049.     XtAddCallback(doneButton, XtNcallback, (XtCallbackProc) ui_popupDone,                 (caddr_t) UI_POPUP_LAYER);
  1050.  
  1051.     ui_checkWindowPosition(ui_popLayer);
  1052.     XtPopup(ui_popLayer, XtGrabExclusive);
  1053.     ui_xDontResizeWidget(ui_popLayer); 
  1054.  
  1055.     ui_pop_exit = FALSE;
  1056.     while (NOT ui_pop_exit) { /* exit after pressing the DONE button */
  1057.     XtAppNextEvent(ui_appContext, &event);
  1058.     (void) XtDispatchEvent(&event);
  1059.     }
  1060. }
  1061.  
  1062.  
  1063. /*****************************************************************************
  1064.   FUNCTION : ui_refresh
  1065.  
  1066.   PURPOSE  : Refresh of a network graphic window case of an expose event
  1067.   RETURNS  : void
  1068.   NOTES    :
  1069.  
  1070.   UPDATE   : 15.5.1990
  1071. ******************************************************************************/
  1072.  
  1073. static void ui_refresh (Widget w, struct Ui_DisplayType *displayPtr, XEvent *event)
  1074.  
  1075. {
  1076.     switch ((*event).type) {
  1077.       case Expose:
  1078.     if (event->xexpose.count == 0) {
  1079.  
  1080.         ui_xGetDimensions(displayPtr->widget, 
  1081.                   &(displayPtr->width), 
  1082.                   &(displayPtr->height));
  1083.     
  1084.         displayPtr->unitsInX = 
  1085.         displayPtr->width  / displayPtr->gridSize;
  1086.         displayPtr->unitsInY = 
  1087.         displayPtr->height / displayPtr->gridSize;
  1088.         ui_net_completeRefresh(displayPtr, UI_LOCAL); 
  1089.     }
  1090.     break;
  1091.       case ConfigureNotify:
  1092.     ui_xGetDimensions(displayPtr->widget, 
  1093.               &(displayPtr->width), 
  1094.               &(displayPtr->height));
  1095.     displayPtr->unitsInX = 
  1096.         displayPtr->width  / displayPtr->gridSize;
  1097.     displayPtr->unitsInY = 
  1098.         displayPtr->height / displayPtr->gridSize;
  1099.     break;
  1100.     }
  1101. }
  1102.  
  1103.  
  1104. /*****************************************************************************
  1105.   FUNCTION : ui_displayGraphic
  1106.  
  1107.   PURPOSE  : display a graphic window
  1108.   RETURNS  : void
  1109.   NOTES    :
  1110.  
  1111.   UPDATE   : 1.4.1990
  1112. ******************************************************************************/
  1113.  
  1114. void ui_displayGraphic (Widget button, struct Ui_DisplayType *displPtr, 
  1115.     caddr_t call_data)
  1116.  
  1117. {
  1118.     Widget         fbutton;
  1119.     Arg           args[10];
  1120.     Cardinal       n;
  1121.     char           buf[40];
  1122.     XtTranslations trans;
  1123.    
  1124.     struct Ui_DisplayType  *displayPtr;
  1125.  
  1126.     if (displPtr == NULL) {
  1127.     /* call from the GUI menue */
  1128.     if ((displayPtr = ui_displ_getFreeItem()) == NULL) {
  1129.         ui_confirmOk("No more memory for displays available!");
  1130.         return;
  1131.     }
  1132.     } else
  1133.     /* call from ui_cfg_load() */
  1134.     displayPtr = displPtr;
  1135.  
  1136.     sprintf(buf,"snns-display %d - subnet: %d",
  1137.         displayPtr->displayNo, displayPtr->subNetNo);
  1138.  
  1139.     n = 0;
  1140.     if (displPtr != NULL) {
  1141.     /* give window manager hints */
  1142.     }
  1143.  
  1144.     ui_popCanvas = 
  1145.     XtCreatePopupShell(buf, topLevelShellWidgetClass, ui_toplevel,
  1146.                args, n);
  1147.  
  1148.     ui_display  = XtDisplay(ui_popCanvas);
  1149.     ui_screen   = DefaultScreen(ui_display);
  1150.  
  1151.     /* now create the display structure to held data */
  1152.  
  1153.     displayPtr->frameWidget = 
  1154.     XtCreateManagedWidget("form", formWidgetClass, ui_popCanvas, 
  1155.                   NULL, ZERO);
  1156.  
  1157.     fbutton = ui_xCreateButtonItem("done", displayPtr->frameWidget, NULL, NULL);
  1158.     XtAddCallback(fbutton, XtNcallback, (XtCallbackProc) ui_displayDone, 
  1159.           (struct Ui_DisplayType  *) displayPtr);
  1160.  
  1161.     fbutton = ui_xCreateButtonItem("setup", displayPtr->frameWidget, fbutton, NULL);
  1162.     XtAddCallback(fbutton, XtNcallback, (XtCallbackProc) ui_popupSetup, 
  1163.           (struct Ui_DisplayType *) displayPtr);
  1164.  
  1165.     fbutton = ui_xCreateToggleItem("freeze", displayPtr->frameWidget, NULL, fbutton, NULL);
  1166.     ui_xSetToggleState(fbutton, displayPtr->frozen);
  1167.     XtAddCallback(fbutton, XtNcallback, (XtCallbackProc) ui_displ_freezeDisplay, 
  1168.           (struct Ui_DisplayType *) displayPtr);
  1169.  
  1170.     n = 0;
  1171.     XtSetArg(args[n], XtNwidth,  displayPtr->width); n++;
  1172.     XtSetArg(args[n], XtNheight, displayPtr->height); n++;
  1173.     XtSetArg(args[n], XtNfromVert, fbutton); n++;
  1174.     XtSetArg(args[n], XtNleft  , XtChainLeft); n++;
  1175.     XtSetArg(args[n], XtNright , XtChainRight); n++;
  1176.     XtSetArg(args[n], XtNtop   , XtChainTop); n++;
  1177.     XtSetArg(args[n], XtNbottom, XtChainBottom); n++;
  1178.     displayPtr->widget = 
  1179.     XtCreateManagedWidget("display", boxWidgetClass, 
  1180.                   displayPtr->frameWidget, args, n);
  1181.     trans =
  1182.     XtParseTranslationTable("Ctrl<Btn1Down>: XawPositionSimpleMenu(popmenu) MenuPopup(popmenu)");
  1183.     
  1184.     XtAugmentTranslations(displayPtr->widget, trans);                     
  1185.     
  1186.  
  1187.     XtAddEventHandler(displayPtr->widget, ExposureMask, GraphicsExpose, 
  1188.               (XtEventHandler) ui_refresh, (struct Ui_DisplayType *) displayPtr);
  1189.     XtAddEventHandler(ui_popCanvas, StructureNotifyMask | SubstructureNotifyMask, FALSE, 
  1190.               (XtEventHandler) ui_refresh, (struct Ui_DisplayType *) displayPtr);
  1191.     XtAddEventHandler(displayPtr->widget, 
  1192.               ButtonPressMask | ButtonMotionMask | ButtonReleaseMask 
  1193.               | EnterWindowMask | LeaveWindowMask,
  1194.               FALSE, (XtEventHandler) ui_mw_eventProc, 
  1195.               (struct Ui_DisplayType *) displayPtr);
  1196.     XtAddEventHandler(displayPtr->widget, 
  1197.               KeyPressMask, FALSE, (XtEventHandler) ui_can_KEventProc, 
  1198.               (struct Ui_DisplayType *) displayPtr);
  1199.     XtAddEventHandler(ui_popCanvas, StructureNotifyMask,
  1200.               FALSE, (XtEventHandler) ui_can_MapEventProc, 
  1201.               (struct Ui_DisplayType *) displayPtr);
  1202.  
  1203.     ui_checkWindowPosition(ui_popCanvas);
  1204.     XtPopup(ui_popCanvas, XtGrabNone);
  1205.  
  1206.     displayPtr->drawable = XtWindow(displayPtr->widget);
  1207.  
  1208.     ui_xToggleBackingStore(TRUE, ui_display, displayPtr->drawable);
  1209.  
  1210.     XSelectInput(ui_display, displayPtr->drawable, 
  1211.          ExposureMask | PointerMotionMask |
  1212.          ButtonPressMask | ButtonMotionMask | ButtonReleaseMask |
  1213.          KeyPressMask | EnterWindowMask | LeaveWindowMask);
  1214.  
  1215.     XGrabButton(ui_display, AnyButton, AnyModifier, displayPtr->drawable, TRUE,
  1216.         ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
  1217.         GrabModeAsync, GrabModeAsync, None,
  1218.         XCreateFontCursor(ui_display, XC_crosshair));
  1219. }
  1220.  
  1221.  
  1222. /*****************************************************************************
  1223.   FUNCTION : ui_textLook
  1224.  
  1225.   PURPOSE  : callback. Called when clicked on the LOOK button 
  1226.   RETURNS  : void
  1227.   NOTES    :
  1228.  
  1229.   UPDATE   : 1.5.1990
  1230. ******************************************************************************/
  1231.  
  1232. static void ui_textLook (Widget widget, XtPointer  client_data, XtPointer call_data)
  1233.  
  1234. {
  1235.     Widget           w, src;
  1236.     XawTextBlock     textBlock;
  1237.     XawTextPosition  start, end, found; /* int ! */
  1238.     char             buf[80],sWord[SEARCH_WORD_MAXLEN+1];
  1239.     Cardinal         n;
  1240.     Arg              args[5];
  1241.  
  1242.     w = (Widget) client_data; 
  1243.     
  1244.     XawTextGetSelectionPos(w, &start, &end);
  1245.  
  1246.     if (start != end) {
  1247.     if ((end-start+1) > SEARCH_WORD_MAXLEN) 
  1248.         end = start + SEARCH_WORD_MAXLEN;
  1249.  
  1250.     n = 0;
  1251.     XtSetArg(args[n], XtNtextSource, &src); n++;
  1252.     XtGetValues(w, args, n);
  1253.      
  1254.     found = XawTextSourceRead(src, (int) start, &textBlock, (int) (end-start));
  1255.  
  1256.     textBlock.firstPos = 0;
  1257.     textBlock.length   = end - start;
  1258.     textBlock.format   = FMT8BIT;
  1259.     
  1260.  
  1261.     XawTextSetInsertionPoint(w, 0);
  1262.     found = XawTextSearch(w, XawsdRight, &textBlock);
  1263.     if (found > 0) {
  1264.         strncpy(sWord, textBlock.ptr, (unsigned int) (end - start));
  1265.         sWord[end-start] = '\0';
  1266. #ifdef DEBUG
  1267.         sprintf(buf, "Found: <%s>", sWord);
  1268.         ui_printMessage(buf);
  1269. #endif
  1270.         XawTextSetInsertionPoint(w, (int) (ui_lengthOfHelp));
  1271.         XawTextSetInsertionPoint(w, (int) (found + textBlock.length));
  1272.         XawTextSetSelection(w, (int) found, 
  1273.                 (int) (found + textBlock.length));
  1274.         XawTextInvalidate(w, (int) found, 
  1275.                   (int) (found + textBlock.length));
  1276.     }
  1277.     }    
  1278. }
  1279.  
  1280.  
  1281. /*****************************************************************************
  1282.   FUNCTION : ui_textMore
  1283.  
  1284.   PURPOSE  : callback. Called when clicked on the MORE button
  1285.   RETURNS  : void
  1286.   NOTES    :
  1287.  
  1288.   UPDATE   : 1.5.1990
  1289. ******************************************************************************/
  1290.  
  1291. static void ui_textMore (Widget widget, XtPointer client_data, XtPointer call_data)
  1292.  
  1293. {
  1294.     Widget           w, src;
  1295.     XawTextBlock     textBlock;
  1296.     XawTextPosition  start, end, found; /* int ! */
  1297.     char             buf[80],sWord[SEARCH_WORD_MAXLEN+1];
  1298.     Cardinal         n;
  1299.     Arg              args[5];
  1300.  
  1301.     w = (Widget) client_data; 
  1302.     
  1303.     XawTextGetSelectionPos(w, &start, &end);
  1304.  
  1305.     if (start != end) {
  1306.     if ((end-start+1) > SEARCH_WORD_MAXLEN) 
  1307.         end = start + SEARCH_WORD_MAXLEN;
  1308.  
  1309.     n = 0;
  1310.     XtSetArg(args[n], XtNtextSource, &src); n++;
  1311.     XtGetValues(w, args, n);
  1312.      
  1313.     found = XawTextSourceRead(src, (int) start, &textBlock, 
  1314.                   (int) (end-start));
  1315.  
  1316.     textBlock.firstPos = 0;
  1317.     textBlock.length   = end - start;
  1318.     textBlock.format   = FMT8BIT;
  1319.     
  1320.     /* XawTextSetInsertionPoint(w, 0); */
  1321.     found = XawTextSearch(w, XawsdRight, &textBlock);
  1322.     if (found > 0) {
  1323.         strncpy(sWord, textBlock.ptr, (unsigned int) (end - start));
  1324.         sWord[end-start] = '\0';
  1325. #ifdef DEBUG
  1326.           sprintf(buf, "Found: <%s>", sWord);
  1327.         ui_printMessage(buf);
  1328. #endif
  1329.         XawTextSetInsertionPoint(w, (int) (ui_lengthOfHelp));
  1330.         XawTextSetInsertionPoint(w, (int) (found + textBlock.length));
  1331.         XawTextSetSelection(w, (int) found, 
  1332.                 (int) (found + textBlock.length));
  1333.  
  1334.         XawTextInvalidate(w, (int) found, 
  1335.                   (int) (found + textBlock.length));
  1336.     }    
  1337.     }
  1338. }
  1339.  
  1340.  
  1341. /*****************************************************************************
  1342.   FUNCTION : ui_textKey
  1343.  
  1344.   PURPOSE  : searches in the specified ascii widget for a key string
  1345.   RETURNS  : void
  1346.   NOTES    :
  1347.  
  1348.   UPDATE   : 1.5.1990
  1349. ******************************************************************************/
  1350.  
  1351. static void ui_textKey  (Widget w, char *key)
  1352.  
  1353. {
  1354.     XawTextBlock     textBlock;
  1355.     XawTextPosition  found; /* int ! */
  1356.     char             buf [80];
  1357.  
  1358.     if (strlen(key) < 1) return;
  1359.  
  1360.     textBlock.ptr      = key;
  1361.     textBlock.firstPos = 0;
  1362.     textBlock.length   = strlen(key);
  1363.     textBlock.format   = FMT8BIT;
  1364.     
  1365.     XawTextSetInsertionPoint(w, 0);
  1366.     found = XawTextSearch(w, XawsdRight, &textBlock);
  1367.     if (found > 0) {
  1368. #ifdef DEBUG
  1369.     sprintf(buf, "Found: <%s>", key);
  1370.     ui_printMessage(buf);
  1371. #endif
  1372.     XawTextSetInsertionPoint(w, (int) (ui_lengthOfHelp));
  1373.     XawTextSetInsertionPoint(w, (int) (found + textBlock.length));
  1374.     XawTextSetSelection(w, (int) found, 
  1375.                 (int) (found + textBlock.length));
  1376.     XawTextInvalidate(w, (int) found, 
  1377.               (int) (found + textBlock.length));
  1378.     }    
  1379. }
  1380.  
  1381.  
  1382. /*****************************************************************************
  1383.   FUNCTION : ui_textTopics
  1384.  
  1385.   PURPOSE  : callback. Called when clicked on the TOPICS button
  1386.   RETURNS  : void
  1387.   NOTES    :
  1388.  
  1389.   UPDATE   : 1.5.1990
  1390. ******************************************************************************/
  1391.  
  1392. static void ui_textTopics (Widget widget, Widget client_data, caddr_t call_data)
  1393.  
  1394. {
  1395.     ui_textKey(client_data, "* TOPICS");
  1396. }
  1397.     
  1398.  
  1399. /*****************************************************************************
  1400.   FUNCTION : ui_displayRemote
  1401.  
  1402.   PURPOSE  : display remote-panel
  1403.   RETURNS  : void
  1404.   NOTES    :
  1405.  
  1406.   UPDATE   : 26.9.1990
  1407. ******************************************************************************/
  1408.  
  1409. void ui_displayRemote (Widget w, caddr_t client_data, caddr_t call_data)
  1410.  
  1411. {
  1412.     Widget      doneButton, form;
  1413.  
  1414.     if (ui_remoteIsCreated) {
  1415.     ui_confirmOk("Remote panel is already created!");
  1416.     return;
  1417.     }
  1418.     
  1419.     ui_popRemote = 
  1420.     XtCreatePopupShell("snns-remote", topLevelShellWidgetClass, ui_toplevel,
  1421.                NULL, ZERO);
  1422.  
  1423.     form =   
  1424.     XtCreateManagedWidget("form", formWidgetClass, ui_popRemote, 
  1425.                   NULL, ZERO);
  1426.  
  1427.     ui_xCreateRemotePanel(form); 
  1428.     
  1429.  /*   n = 0;
  1430.     XtSetArg(args[n], XtNfromHoriz, NULL);       n++;
  1431.     XtSetArg(args[n], XtNfromVert , ui_stat_selNoWidget); n++;
  1432.     XtSetArg(args[n], XtNleft  , XtChainLeft);   n++;
  1433.     XtSetArg(args[n], XtNright , XtChainLeft);   n++;
  1434.     XtSetArg(args[n], XtNtop   , XtChainTop);    n++;
  1435.     XtSetArg(args[n], XtNbottom, XtChainTop);    n++;    
  1436.     XtSetValues(ui_remotePanel, args, n);
  1437.     */
  1438.  
  1439.     doneButton = 
  1440.     ui_xCreateButtonItem("done", form, NULL, ui_remotePanel);
  1441.     XtAddCallback(doneButton, XtNcallback, (XtCallbackProc) ui_popupDone, (caddr_t) UI_POPUP_REMOTE);
  1442.  
  1443.     ui_remoteMessageWidget =
  1444.     ui_xCreateLabelItem("message",form, 10*8, 
  1445.                 doneButton, ui_remotePanel); 
  1446.     ui_xSetResize(ui_remoteMessageWidget, TRUE);
  1447.     ui_xSetLabel(ui_remoteMessageWidget, "");
  1448.  
  1449.     XawFormDoLayout(form, True);
  1450.     ui_checkWindowPosition(ui_popRemote);
  1451.     XtPopup(ui_popRemote, XtGrabNone);
  1452.     ui_xDontResizeWidget(ui_popRemote); 
  1453.    ui_file_updateShellLabels();
  1454. }
  1455.  
  1456.  
  1457. /*****************************************************************************
  1458.   FUNCTION : ui_displayText
  1459.  
  1460.   PURPOSE  : display a help window
  1461.   RETURNS  : void
  1462.   NOTES    : returns false if no help.hdoc found
  1463.  
  1464.   UPDATE   : 1.5.1990
  1465. ******************************************************************************/
  1466.  
  1467. void ui_displayText (Widget button, caddr_t client_data, caddr_t call_data)
  1468.  
  1469. {
  1470.     Widget      doneButton, lookButton, moreButton, topicsButton, form;
  1471.     Arg        args[12];
  1472.     Cardinal    n;
  1473.     char        buf[20];
  1474.     char        hdoc[MAX_NAME_LENGTH];
  1475.     struct stat *help_size_buf;
  1476.  
  1477.     struct HelpType *listPtr;
  1478.  
  1479.     sprintf(hdoc, "help.hdoc");
  1480.     if (NOT ui_fileExist(hdoc,0)) {
  1481.     if (getenv("XGUILOADPATH") != NULL) 
  1482.         sprintf(hdoc, "%s/help.hdoc", getenv("XGUILOADPATH"));
  1483.     if (NOT ui_fileExist(hdoc,0)) {
  1484.         ui_confirmOk("Can't display help. <help.hdoc> not found.");
  1485.             ui_helpOk = FALSE;
  1486.         return;
  1487.     }
  1488.     }
  1489.  
  1490.     /* getting the length of the helpfile */
  1491.     help_size_buf = (struct stat *) malloc(sizeof(struct stat));
  1492.     if (help_size_buf == NULL) {
  1493.         ui_confirmOk("No memory available to display a new help window!");
  1494.             ui_helpOk = FALSE;
  1495.         return;
  1496.     }
  1497.     stat (hdoc, help_size_buf);
  1498.     ui_lengthOfHelp = help_size_buf->st_size;
  1499.     free (help_size_buf);
  1500.  
  1501.     /* first get a free help item */
  1502.     if (ui_help_freeListPtr == NULL) { /* no free item */
  1503.     listPtr = (struct HelpType *) (malloc(sizeof(struct HelpType)));
  1504.     if (listPtr == NULL) {
  1505.         ui_confirmOk("No memory available to display a new help window!");
  1506.             ui_helpOk = FALSE;
  1507.         return;
  1508.     }        
  1509.     listPtr->no = ++ui_noOfHelpsUp;
  1510.     } else {
  1511.     listPtr = ui_help_freeListPtr;
  1512.     ui_help_freeListPtr = listPtr->nextPtr;
  1513.     }
  1514.     /* link it in normal list */
  1515.     listPtr->nextPtr = ui_help_listPtr;
  1516.     ui_help_listPtr  = listPtr;
  1517.  
  1518.     sprintf(buf,"snns-help %d",listPtr->no);
  1519.     listPtr->shellWidget =     XtCreatePopupShell(buf, topLevelShellWidgetClass, ui_toplevel,
  1520.                NULL, ZERO);
  1521.  
  1522.     form =   
  1523.     XtCreateManagedWidget("form", formWidgetClass, listPtr->shellWidget, 
  1524.                   NULL, ZERO);
  1525.  
  1526.     doneButton = 
  1527.     ui_xCreateButtonItem("done", form, NULL, NULL);
  1528.     XtAddCallback(doneButton, XtNcallback, (XtCallbackProc) ui_helpDone, 
  1529.           (struct HelpType *) listPtr); 
  1530.  
  1531.     lookButton = 
  1532.     ui_xCreateButtonItem("look", form,   doneButton, NULL);
  1533.  
  1534.     moreButton = 
  1535.     ui_xCreateButtonItem("more", form,   lookButton, NULL);
  1536.  
  1537.     topicsButton = 
  1538.     ui_xCreateButtonItem("topics", form, moreButton, NULL);
  1539.  
  1540.     /* ui_help_messageWidget =
  1541.        ui_xCreateLabelItem("", form, 80*8, topicsButton, NULL);
  1542.        ui_xSetResize(ui_help_messageWidget, TRUE);
  1543.     */
  1544.     
  1545.     n = 0;
  1546.     XtSetArg(args[n], XtNwidth,  575); n++;
  1547.     XtSetArg(args[n], XtNheight, 400); n++;
  1548.     XtSetArg(args[n], XtNtype, XawAsciiFile); n++;
  1549.     XtSetArg(args[n], XtNstring, hdoc); n++;
  1550.     XtSetArg(args[n], XtNscrollVertical, XawtextScrollAlways); n++;
  1551.     XtSetArg(args[n], XtNfromVert , doneButton);  n++;
  1552.     XtSetArg(args[n], XtNfromHoriz, NULL);  n++;
  1553.     XtSetArg(args[n], XtNleft  , XtChainLeft);   n++;
  1554.     XtSetArg(args[n], XtNright , XtChainLeft);   n++;
  1555.     XtSetArg(args[n], XtNtop   , XtChainTop);    n++;
  1556.     XtSetArg(args[n], XtNbottom, XtChainTop);    n++;    
  1557.     listPtr->textWidget = 
  1558.     XtCreateManagedWidget("textWin", asciiTextWidgetClass, form, args, n);
  1559.  
  1560.     XtAddCallback(lookButton,   XtNcallback, ui_textLook,   
  1561.           (XtPointer) listPtr->textWidget);
  1562.     XtAddCallback(moreButton,   XtNcallback, ui_textMore,   
  1563.           (XtPointer) listPtr->textWidget);
  1564.     XtAddCallback(topicsButton, XtNcallback, (XtCallbackProc) ui_textTopics, 
  1565.           (XtPointer) listPtr->textWidget);
  1566.  
  1567.     XawFormDoLayout(form, True);
  1568.     ui_checkWindowPosition(listPtr->shellWidget);
  1569.     XtPopup(listPtr->shellWidget, XtGrabNone);
  1570.     ui_xDontResizeWidget(listPtr->shellWidget); 
  1571.     ui_helpOk = TRUE;
  1572. }
  1573.  
  1574.  
  1575. /*****************************************************************************
  1576.   FUNCTION : ui_displayHelp
  1577.  
  1578.   PURPOSE  : show a help window and the first position where the key string
  1579.              was found
  1580.   RETURNS  : void
  1581.   NOTES    :
  1582.  
  1583.   UPDATE   : 1.2.1990
  1584. ******************************************************************************/
  1585.  
  1586. void  ui_displayHelp (char *key)
  1587.  
  1588. {
  1589.     if (ui_help_listPtr != NULL) {
  1590.     /* there are help windows opened */
  1591.     /* get one, which is not iconified */
  1592.     /* struct HelpType *listPtr;
  1593.        listOtr = ui_help_listPtr;
  1594.        while ((listPtr != NULL) AND listPtr->unmapped)
  1595.        listPtr = listPtr->nextPtr;
  1596.        if (listPtr == NULL) {
  1597.        } else
  1598.        */
  1599.     XMapRaised(ui_display, XtWindow(ui_help_listPtr->shellWidget));
  1600.     ui_textKey(ui_help_listPtr->textWidget, key);
  1601.     } else {
  1602.     ui_displayText(NULL, NULL, NULL); /* popup a window */
  1603.         if (ui_helpOk)
  1604.          ui_textKey(ui_help_listPtr->textWidget, key);
  1605.     }
  1606. }
  1607.  
  1608.  
  1609. /*****************************************************************************
  1610.   FUNCTION : ui_guiQuit()
  1611.  
  1612.   PURPOSE  : leave XGUI
  1613.   RETRURNS : void
  1614.   NOTES    : erases all temp files
  1615.  
  1616.   UPDATE   : 15.5.1992
  1617. ******************************************************************************/
  1618.  
  1619. /*ARGSUSED*/
  1620. void ui_guiQuit (Widget widget, XtPointer client_data, XtPointer call_data)
  1621.  
  1622. {
  1623.     char cmdLine[200];
  1624.  
  1625.     if (ui_confirmYes("Do you really want to quit?")) {
  1626.     krui_deleteNet();
  1627.         sprintf (cmdLine, "/bin/rm -f %s/%s* > /dev/null", ui_tmpDir, ui_praefix); 
  1628.         system (cmdLine);
  1629.  
  1630.  /* free all memory used by the kernel */
  1631.     XtDestroyApplicationContext(XtWidgetToApplicationContext(widget));
  1632.     exit(0);
  1633.     }
  1634. }
  1635.  
  1636.  
  1637. #ifdef _UNUSED_FUNCTIONS_
  1638.  
  1639.  
  1640. /*****************************************************************************
  1641.   FUNCTION : ui_syntax
  1642.  
  1643.   PURPOSE  :
  1644.   RETURNS  : void
  1645.   NOTES    :
  1646.  
  1647.   UPDATE   : 1.2.1990
  1648. ******************************************************************************/
  1649.  
  1650.  
  1651. static void ui_syntax (XtAppContext app_con, char *call)
  1652.  
  1653. {
  1654.     XtDestroyApplicationContext(app_con);
  1655.     fprintf(stderr, "Usage: %s\n", call);
  1656.     exit(1);
  1657. }
  1658.  
  1659.  
  1660. #endif /* _UNUSED_FUNCTIONS_ */
  1661.  
  1662.  
  1663. /*****************************************************************************
  1664.   FUNCTION : ui_loadFileFromCommandLine
  1665.  
  1666.   PURPOSE  : load files from command line
  1667.   RETURNS  : void
  1668.   NOTES    : load default if no cfg specified
  1669.  
  1670.   UPDATE   : 15.6.1992
  1671. ******************************************************************************/
  1672.  
  1673. void ui_loadFileFromCommandLine (void)
  1674. {
  1675.     if (ui_loadNetbyInit) 
  1676.        ui_file_loadNet((Widget) ZERO, (XtPointer) NULL, (caddr_t) NULL);
  1677.     if (ui_loadPatbyInit) 
  1678.        ui_file_loadPatterns((Widget) ZERO, (XtPointer) NULL, (caddr_t) NULL);
  1679.  
  1680.     if (ui_loadCfgbyInit) 
  1681.        ui_file_loadConfiguration((Widget) ZERO, (XtPointer) NULL, (caddr_t) NULL);
  1682.     else
  1683.         ui_file_loadDefaultConfiguration(ui_pathname);
  1684. }
  1685.  
  1686.  
  1687. /*****************************************************************************
  1688.   FUNCTION : ui_chkFileName
  1689.  
  1690.   PURPOSE  : check extention for a given filename
  1691.   RETURNS  : int
  1692.   NOTES    :
  1693.  
  1694.   UPDATE   : 15.6.1992
  1695. ******************************************************************************/
  1696.  
  1697. static int ui_chkFileName (char *s1, char *s2)
  1698.  
  1699. {
  1700.     return (!strcmp(s1+strlen(s1)-4, s2));
  1701. }
  1702.  
  1703.  
  1704. /*****************************************************************************
  1705.   FUNCTION : ui_showHelpMsg
  1706.  
  1707.   PURPOSE  : displays a help message
  1708.   RETURNS  : void
  1709.   NOTES    :
  1710.  
  1711.   UPDATE   : 15.6.1992
  1712. ******************************************************************************/
  1713.  
  1714. static void ui_showHelpMsg (char *call)
  1715.  
  1716. {
  1717.     fprintf(stderr, "\n\n       Stuttgart Neural Network Simulator  V 3.1\n\n");
  1718.     fprintf(stderr, "  usage  %s [netfile] [patternfile] [configuration] [options]\n\n", call);
  1719.     fprintf(stderr, "  where options are -font <name>   font for the simulator\n");  
  1720.     fprintf(stderr, "                    -dfont <name>  font for the displays\n");  
  1721.     fprintf(stderr, "                    -mono          black & white on color screens \n");  
  1722.     fprintf(stderr, "                    -help          this help\n");  
  1723.     fprintf(stderr, "\n\n");
  1724. }
  1725.  
  1726.  
  1727. /*****************************************************************************
  1728.   FUNCTION : ui_parseCmdLine
  1729.  
  1730.   PURPOSE  : parse command line
  1731.   RETURNS  : void
  1732.   NOTES    : sets options and filenames
  1733.  
  1734.   UPDATE   : 15.6.1992
  1735. ******************************************************************************/
  1736.  
  1737. void ui_parseCmdLine (XtAppContext app_con, int noParams, char *params[])
  1738.  
  1739. {
  1740.      int i;
  1741.      char *call;
  1742.  
  1743.      call = *params;
  1744.  
  1745.      i = 0;
  1746.      while(++i != noParams) {
  1747.          if (*params[i] == '-') {
  1748.              if ((strcmp(params[i], "-dfont")) == 0) {
  1749.                  if(params[++i] == NULL){
  1750.                      ui_tw_errorMessage("No Font specified");
  1751.                      exit(1);
  1752.                  }else{
  1753.                      strcpy (ui_fontName, params[i]);
  1754.                      hasCmdlineFont = TRUE;
  1755.                  }
  1756.          } else {
  1757.                  if ((strcmp(params[i], "-mono")) == 0) {
  1758.                      ui_monoOnColorScreen = TRUE;
  1759.              } else {
  1760.                      if ((strcmp(params[i], "-help") == 0) 
  1761.                        OR (strcmp(params[i], "-h") == 0)) {
  1762.                          ui_showHelpMsg(call);
  1763.                          exit(1);
  1764.                      } else {
  1765.                          if ((strcmp(params[i], "-font")) == 0) {
  1766.                              hasCmdlineFont = TRUE;
  1767.                          }
  1768.                      }
  1769.          }
  1770.          }
  1771.          } else {
  1772.              if (ui_chkFileName(params[i], ".net")) {
  1773.                  strncpy(ui_filenameNET, params[i], strlen(params[i])-4);
  1774.                  ui_loadNetbyInit = TRUE;
  1775.          } else {
  1776.                  if (ui_chkFileName(params[i], ".pat")) {
  1777.                      strncpy(ui_filenamePAT, params[i], strlen(params[i])-4);
  1778.                      ui_loadPatbyInit = TRUE;
  1779.                 } else {
  1780.                     if (ui_chkFileName(params[i], ".cfg")) {
  1781.                         strncpy(ui_filenameCFG, params[i], strlen(params[i])-4);
  1782.                         ui_loadCfgbyInit = TRUE;
  1783.                         ui_loadCorrespondingCfg = FALSE;
  1784.             }
  1785.          }
  1786.          }
  1787.          }
  1788.  
  1789.      }
  1790. }
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796. /* end of file */
  1797. /* lines: 1705 */
  1798.